import request from '@/utils/request'

function getRobotList(params) {
  return request({
    url: '/sysapi/GetRobotList',
    method: 'post',
    params
  })
}
function RestartRobot(robotId) {
  return request({
    url: '/sysapi/RestartRobot',
    method: 'post',
    params: { robotId: robotId }
  })
}
function StopRobot(robotId) {
  return request({
    url: '/sysapi/StopRobot',
    method: 'post',
    params: { robotId: robotId }
  })
}
/**
 * @param {Number} period
 * @param {Number} trend 0,1,-1,2;Binance:BTCUSDT:60 headers: { 'Content-Type': 'application/json' }
 * @param {String} pair BTCUSDT
 */
function TrendSet(period, trend, pair) {
  const pairVar = pair || 'BTCUSDT'
  return request({
    url: `/UserData/SetUserData`,
    method: 'post',
    params: { key: `Binance:${pairVar}:${period}`, value: trend }
  })
}

/**
 *
 * @param {*} params RobotInfo
 */
function newRobot(data) {
  return request({
    url: '/sysapi/NewRobot',
    method: 'post',
    data
  })
}
function RemoveRobot(id) {
  return request({
    url: '/Robot/Remove',
    method: 'post',
    data: { id: id }
  })
}
/**
 *
 * @param {*} params StrategyInfo
 */
function getStrategyList(params) {
  return request({
    url: '/sysapi/GetStrategyList',
    method: 'post',
    params
  })
}
function editRobotStrategyArgs(robotId, data) {
  return request({
    url: '/Robot/EditStrategyArgs',
    method: 'post',
    params: { robotId: robotId },
    data
  })
}
/**
 *
 * @param {*} params  long robotId, int pageNum, int pageSize
 * @returns Tuple<long, LogInfo[]>
 */
function getRobotLogs(params) {
  return request({
    url: '/sysapi/GetRobotLogs',
    method: 'get',
    params
  })
}
export default {
  getRobotList,
  RestartRobot,
  StopRobot,
  TrendSet,
  newRobot,
  getStrategyList,
  editRobotStrategyArgs,
  RemoveRobot,
  getRobotLogs

}
